home *** CD-ROM | disk | FTP | other *** search
- {$U+}
- program Print_Two_Sides;
-
- (* A program to print documentation on both sides of the paper.
-
- Written by: Earl Hall
- (10/4/85) 5619 N. Spaulding #3
- Chicago, IL 60659
- CompuServe : 72746,3244
-
-
- This program will print either the 'Right' or 'Left' pages of a
- print file. It was written so that I could print the on-disk
- documentation files provided with "shareware" programs (PC-
- Write, for example) on both sides of the paper. With it you
- first send the 'Right' pages to the printer, then turn the paper
- over for the 'Left' pages. A little experimentation is still
- necessary to get the pages matched properly but, in general, the
- process works quite well.
-
- The terms 'Right' and 'Left' pages refer to which side of the
- bound page the printout is being produced for. (This is all my
- terminology; my apologies if I'm using these terms incorrectly).
- The 'Right' pages will have the text printed to the right of the
- bindings.
-
- Most on-disk documentation files will have, first, a cover sheet
- followed by a table of contents and then the text. To handle
- this kind of situation, you can tell the program how many extra
- leading 'Right' pages are contained in the document. For
- instance, PC-Write's documentation has a cover sheet, then a TOC
- followed by Page 1 of the Introduction. For that file I
- specified that there were 2 extra 'Right' pages, so that the TOC
- and Page 1 would also be 'Right' pages. (I'm desperately trying
- to avoid any "right stuff" puns at the moment, but it's hard.)
-
- The prompt for the 'lines per page' refers to the number of
- possible lines that can be printed on the paper. For normal
- fanfold paper of 11 inches, printed at 6 lpi this number is 66.
- The 'lines below TOF' query refers to how many blank lines would
- be produced below the perforation if a FormFeed character is
- sent to the printer. A lot of on-disk documentation is
- formatted to start at the very top of the page (the print file
- supplies the necessary blank lines for the proper heading
- spacing). Most people align some sort of guide on the print
- head with the perforation - this usually, in fact, produces 1
- blank line after the perforation.
-
- The 'how many blanks to add/subtract' prompt is for adjusting
- left margins. A positive number will add blanks to the
- beginning of the line; a negative number will delete that number
- of CHARACTERS (whether blank or not!) from the beginning of
- lines. This action is not sensitive to whether the action is
- being performed on a 'Right' or 'Left' page. In other words, it
- WILL NOT add blanks to right margin of 'Left' pages.
-
- This program will only work properly if the print file
- consistently uses either formfeeds or blank lines to do the page
- advancing. If the methods are mixed, the program's idea of the
- position of the current printline will be wrong. It also will
- work properly only if the formfeed character is either the first
- or only character on the line.
-
- Other than being a little piece of my late-night soul, I hold no
- claim on this program. Feel free to modify and distribute it to
- others.
-
- P.S.: The documentation for PC-Write is contained in multiple
- data files. To use this program it's best to concatenate (with
- a COPY <file>+<file>+... command) all of them into one large
- file. PC-Write's documentation has to be converted to normal
- text files, with the FILEMAN.COM program provided by Quicksoft,
- before this can be done.
- *)
-
- const
- ff = #12;
- many_blanks = ' ';
-
- var
- console_input : string[35];
- temp1, temp2 : integer;
-
- pagelength : integer;
- print_which : integer;
- extra_rights : integer;
- blanks_at_top : integer;
- left_margin : integer;
- current_page : integer;
- lines_printed : integer;
-
- print_buf : array [1..2] of string [255];
- title_in : string [35];
- title_out : string [35];
- file_in : text;
- file_out : text;
-
- procedure increment_page;
- begin
- if extra_rights > 0 then
- extra_rights := extra_rights - 1
- else
- current_page := current_page + 1;
- end;
-
- begin
-
- extra_rights := 0;
- blanks_at_top := 1;
- pagelength := 66;
- left_margin := 0;
- current_page := 1;
- title_out := 'LPT1';
-
- LowVideo;
-
- repeat
- clrscr;
- Write('Enter Input filename: ');
- Readln(title_in);
- assign(file_in,title_in);
- {$I-}
- reset(file_in);
- {$I+}
- until ioresult = 0;
-
- Writeln;
- console_input := '';
-
- Write('Output filename? (Press Enter for LPT1) ');
- Readln(console_input);
- if console_input <> '' then
- title_out := console_input;
-
- Writeln;
-
- Write('Print <R>ight or <L>eft pages? ');
-
- repeat
- console_input := '';
- Read(Kbd,console_input[1]);
- console_input[1] := UpCase(console_input[1]);
- until (console_input[1] = 'R') or (console_input[1] = 'L');
-
- if console_input[1] = 'R' then
- begin
- Writeln('Right');
- print_which := 1;
- end
- else
- begin
- Writeln('Left');
- print_which := 0;
- end;
-
- Writeln;
-
- Write('Number of extra leading pages to be ''Right'' pages? (Enter for 0) ');
- Readln(extra_rights);
-
- Writeln;
-
- Write('Lines per page? (Press Enter for 66) ');
- Readln(pagelength);
-
- Writeln;
-
- Write('Printer is positioned how many lines below TOF? (Enter for 1) ');
- Readln(blanks_at_top);
- lines_printed := blanks_at_top;
-
- Writeln;
-
- Write('How many blanks to add/subtract to left margin? (Enter for 0) ');
- Readln(left_margin);
-
- Writeln;
-
-
- assign(file_in,title_in);
- assign(file_out,title_out);
- reset(file_in);
- rewrite(file_out);
-
-
- while not eof(file_in) do
- begin
- readln(file_in,print_buf[1],print_buf[2]);
- for temp1 := 1 to 2 do
- for temp2 := 1 to length(print_buf[temp1]) do
- if print_buf[temp1][temp2] = ff then
- begin
- lines_printed := blanks_at_top;
- increment_page;
- end;
- if current_page mod 2 = print_which then
- begin
- if left_margin = 0 then
- writeln(file_out,print_buf[1],print_buf[2])
- else
- begin
- if print_buf[1][1] = ff then
- begin { put out ff before adding/stripping blanks }
- print_buf[1] := copy(print_buf[1],2,255);
- write(file_out,ff);
- end;
- if left_margin > 0 then
- writeln(file_out,copy(many_blanks,1,left_margin)
- ,print_buf[1],print_buf[2])
- else
- writeln(file_out,copy(print_buf[1],abs(left_margin - 1),255)
- ,print_buf[2]);
- end;
- end;
- lines_printed := lines_printed + 1;
- if lines_printed = pagelength then
- begin
- lines_printed := 0;
- increment_page;
- end;
- end;
-
- close (file_in);
- close (file_out);
-
- end.